#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import time
import datetime
from multiprocess import Pool


def md2pdf(item):
    "markdown转pdf"
    (mdname, pdfname) = item
    time.sleep(5)
    print('%s转换完成' % mdname)


if __name__ == '__main__':
    start = datetime.datetime.now()
    items = [(str(i) + '.md', str(i) + '.pdf') for i in range(1, 99)] # 构造可迭代参数
    pool = Pool(processes=100) # 创建进程池
    pool.map(md2pdf, items) # 传参
    pool.close() # 关闭pool
    pool.join() # 阻塞当前进程
    end = datetime.datetime.now()
    spend_time = end - start
    print('结束,共消耗时间:%s秒' % spend_time.total_seconds())
